//频道
const channel = new BroadcastChannel('crossTagMag');
//tag标签页的通信
/**
 *
 * @param {'add'| 'edit' | 'save' } type
 * @param {any} msg
 * @returns
 */
//发送消息
export const sendMsg = (type: string, msg?: any) => {
  channel.postMessage({
    type,
    msg,
  });
};
//接受消息
export const listenMsg = (callback: Function) => {
  channel.addEventListener('message', (e: any) => {
    callback && callback(e.data);
  });
};
